# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=pyfastbti
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.r3.da01c14
pkgrel=1
pkgdesc='Python module for quickly handling BTI image files (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/LagoLunatic/PyFastBTI"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "git")
_gitcommit=da01c14562a4711e031fd0a01c52d2131035e228
source=("git+https://github.com/LagoLunatic/PyFastBTI#commit=${_gitcommit}")
sha256sums=('SKIP')

pkgver() {
  cd $srcdir/PyFastBTI
  printf "0.r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "PyFastBTI" "python-build-${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
